/**
 * Created with Vim7.3 ubuntu12.04
 * @fileOverview : 
 * @author : Lyle <lylechen2014@gmial.com>
 * @since : 2014-10-13 14:51:37
 * @filename : static/logic/nmm/src/views/editAboutRelationshipStatus.tpl
 * @version : 
 * @description : 
 */

define(function(require, exports, module){

    var editAboutRelationshipStatusView,userObj,
         mId = 'editAboutRelationshipStatus',reRender = false,menuName = 'editAboutRelationshipStatus',
        imglazyload = require('{component}imglazyload/zepto.imglazyload'),
        panel = require('{component}panel/zepto.panel'),
        tpl = require('{view}editAboutRelationshipStatus.tpl'),
        tplS = require('{view}select.tpl'),
        tplN = require('{view}userNav.tpl');

    editAboutRelationshipStatusView = Backbone.View.extend({

        template: _.template(tpl),
        templateN: _.template(tplN),
        templateS: _.template(tplS),

        bindEvt : function() {
            var tthis = this,dom=$('#'+mId);

            dom.find('.back').on('tap',function(e){
                window.location.href = '#myProfile/whole/custom1'; 
            });

            dom.find('.save').on('tap',function(e){
                var value = dom.find('select').val();
                var usr_id = userObj.account.usr_id;
                var callback = function(){
                    userObj.about.relationship_status = value;
                    share.cacheUserInfo(usr_id,userObj);
                    window.location.href = '#myProfile/whole/custom1'; 
                }
                var obj = {marital : value};
                share.updateProfile(usr_id,callback,obj);
            });
        },      

        render: function (obj) {
            if (!share.checkPermission(true)){return;};  
             share.reRender(reRender,mId); 
            userObj = share.getObjStorage(share.userInfo().usr_id);
            if ($('#'+mId).length < 1) { 
                $('body').append(this.template(lang));
               
                this.bindEvt(); 
            } else {
                $('#'+mId).css('display','block');
            }

            share.panel(panel,this.templateN,mId,menuName);
            var maritalSelect = share.getLocalStorage('ms_marital');
            $('#'+mId).find('#marital').html(this.templateS({obj : maritalSelect, value : userObj.about.relationship_status}));
        }

	});
	module.exports = editAboutRelationshipStatusView;
})

